package com.zrb.mobile.ui;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class MyViewPager extends ViewPager {

	int mLastMotionY;
	int mLastMotionX;
	
	public MyViewPager(Context context) {
		super(context);
	}
	
	public MyViewPager(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	public boolean dispatchTouchEvent(MotionEvent ev) {
		getParent().requestDisallowInterceptTouchEvent(true); //ֻ����仰���ø��಻���ش����¼��Ϳ����ˡ�
        return super.dispatchTouchEvent(ev);
	}
	
	private int downX;
	private int downY;
	
	 
	/*
	@Override
	public boolean dispatchTouchEvent(MotionEvent ev) {
		switch (ev.getAction()) {
		case MotionEvent.ACTION_DOWN:
			//鎸変笅鐨勬椂鍊欙紝澶帶浠朵笉鍙互鍘绘嫤鎴狝CTION_DOWN鐨勪簨浠?			getParent().requestDisallowInterceptTouchEvent(true);
			downX = (int) ev.getX();
			downY = (int) ev.getY();
			break;
		case MotionEvent.ACTION_MOVE:
			int moveX = (int) ev.getX();
			int moveY = (int) ev.getY();
			
			//宸﹀彸绉诲姩绉诲姩鐨勬瘮涓婁笅绉诲姩澶氾紝缈婚〉
			if(Math.abs(moveX-downX)>Math.abs(moveY - downY)){
				getParent().requestDisallowInterceptTouchEvent(true);
			}else{
				getParent().requestDisallowInterceptTouchEvent(false);
			}
			break;
		case MotionEvent.ACTION_CANCEL:
			getParent().requestDisallowInterceptTouchEvent(false);
			break;
		}
		return super.dispatchTouchEvent(ev);
	}*/

	
	
	
	
	
	
	
}

